<%@ page import =  "com.broadvision.web.util.ViewDynaBean,
		    org.apache.struts.validator.DynaValidatorForm,
                    org.apache.commons.beanutils.PropertyUtils,
                    java.util.List"
%>

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>

<jsp:useBean id="cmProcessListView" scope="request" type="com.broadvision.web.util.ViewDynaBean"/> 
<bean:size id="resultSize" name="cmProcessListView" property="processList"/>

<script language="JavaScript">

function closeWindow() {
  self.close();
}

function setProcess(theForm, index) {
  var parentFormName = theForm.parentFormName.value;
  var parentFieldName = theForm.parentFieldName.value;
  
  var ppack = "theForm.elements['process[" + index + "].processPack'].value";
  var processPack = eval(ppack);
  var pname = "theForm.elements['process[" + index + "].processName'].value";
  var processName = eval(pname);
  
  window.opener.setProcessPack(parentFormName, "processPack", processPack);
  window.opener.setProcessName(parentFormName, "processName", processName);
  
  window.close();
}

</script>

<html:form action="/cm/processSearchPopup.do">
<html:hidden property="parentFormName"/>
<html:hidden property="parentFieldName"/>
<html:hidden property="action" value="search" />
<table class="zoneFive" width="100%" border="0" cellspacing="0" cellpadding="0" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.processSearch.criteria'/>">
  <tr>
  <td valign="top" width="100%">
  <div class="generalWrapRight">
  <html:button property="closeWinBtn" styleClass="inputButton" onclick="javascript:closeWindow()">
    <bean:message bundle='cm.messages' key='button.close' />
  </html:button>
  </div> 

  <table class="labelForm" width="100%" border="0" cellspacing="0" cellpadding="2" summary="<bean:message bundle='cm.messages' key='cm.content.processMap.processSearch.criteria'/>">
  <tr> 
  <td width="10%" nowrap><b><bean:message bundle='cm.messages' key='cm.content.processMap.processName'/>:</b></td>
  <td width="30%" nowrap>
    <html:text property="processName" size="31" maxlength="80" />
  </td>
  <td width="10%" nowrap><b><bean:message bundle='cm.messages' key='cm.content.processMap.processPack'/>:</b></td>
  <td width="30%" nowrap>
    <html:text property="processPack" size="31" maxlength="80" />
  </td>
  
  <td width="60%" nowrap>
    <input hspace="40" type="submit" name="btn_action" class="inputButton" value="<bean:message bundle='cm.messages' key='button.goto'/>">
  </td>
  </tr>
  </table>
  
  <logic:match name="cmProcessListView" property="searchResultMsg" value="ShowResults">
  <div class="pageSubtitle">
     <span class="left"><bean:message bundle='cm.messages' key='cm.content.process.list'/></span>
  </div> 
  <table class="dataTable" border="0" cellspacing="1" cellpadding="2" width="100%" summary="<bean:message bundle='cm.messages' key='cm.content.process.list'/>">
  <tr class="listHeader">
    <th id="Process Name" align="left"><bean:message bundle='cm.messages' key='cm.content.processMap.processName'/></th>
    <th id="Process Pack" align="left"><bean:message bundle='cm.messages' key='cm.content.processMap.processPack'/></th>

    <th id="Actions" align="left" nowrap><bean:message bundle='cm.messages' key='cm.content.processMap.actions'/></th>
  </tr>     
  
  <logic:equal name="resultSize" value="0">
  <tr class="listEven"> 
    <td colspan="3" valign="top" align="center"><bean:message bundle='cm.messages' key='cm.content.processMap.noProcessFound'/></td>
  </tr>
  </logic:equal>

  <logic:iterate id="process" name="cmProcessListView" property="processList" indexId="index">  
    <tr class='<%=index.intValue() %2 == 0 ? "listEven" : "listOdd"%>'>
      <td headers="Process Name">
        <bean:write name="process" property="processName"/>
        <html:hidden name="process" property="processName" indexed="true"/>
      </td>
      <td headers="Process Pack">
        <bean:write name="process" property="processPack"/>
        <html:hidden name="process" property="processPack" indexed="true"/>
      </td>
      <td nowrap headers="Actions" align="left">
        <a href="#" onclick="return setProcess(document.forms[0], '<bean:write name="index"/>')">
          <img src="<%=request.getContextPath()%>/mc/images/action/icon_add.gif" width="15" height="15" border="0" alt='<bean:message bundle='cm.messages' key='image.alt.selectitem'/>' title='<bean:message bundle='cm.messages' key='image.alt.selectitem'/>' >
        </a>
      </td>
    </tr>
  </logic:iterate>
  
  </table>
  </logic:match>

  </td>
  </tr>
</table>
</html:form>
